#pragma once
#include <fstream>
#include <sstream>
#include "branch.h"
#include "param.h"
#include "Eigen/Dense"
using namespace std;
using namespace Eigen;
class electric_base
{
public:
    double delt;
    double simulation_time;
    branches brs;
    string name;

    virtual void begin(param &Params) {}
    virtual void dsdyn_out_iteration(double delt = 0.0, double simulation_time = 0.0) {}
    virtual void dsout_out_iteration(Vector2d &V) {}
    virtual void dsout_out_iteration(Vector3d &V) {}
    virtual void dsout_out_iteration(double &V) {}

    void generate_map(string path)
    {
        ofstream fout(path);
        if (!fout)
            exit(-44);
        fout << "Vmap:" << endl;
        for (auto it = brs.Vmap.begin(); it != brs.Vmap.end(); it++)
            fout << it->first
                 << "\t\t\t\t" << it->second << endl;
        fout << endl;
        fout << "Branches:" << endl;
        for (branch &br : brs.branch_list)
            fout << br.name
                 << "\t\t\t\t" << br.from_tag << "\t\t\t\t" << br.to_tag << "\t\t\t\t"
                 << br.from_node << "\t\t\t\t" << br.to_node << endl;

        fout << "\nEndpage:" << endl;
    }
};